import { listAddress, deleteAddress } from '@/api/custom'
import { toast } from '@/utils/extendApi'
Page({
  /**
   * 组件的初始数据
   */
  data: {
    addressList: []
  },
  onShow() {
    this.getAddress()
  },
  getAddress() {
    listAddress().then(res => {
      this.setData({
        addressList: res.data
      })
    })
  },
  toEdit(e: any) {
    wx.navigateTo({ url: './edit_address/edit_address?id=' + e.target.id })
  },
  deleteAddress(event: any) {
    deleteAddress(event.target.id).then(res => {
      toast({ title: '删除成功', icon: 'success' })
      this.getAddress();
    })

  }
})